package day25;

public class Thread01 extends Thread {
    public static int ticketNum = 1000;

    @Override
    public void run() {
        try {
            while (true) {
                synchronized (Thread01.class) {
                    sleep(3000);
                    if (ticketNum > 0) {
                        ticketNum--;
                        System.out.println(Thread.currentThread().getName() + "剩余" + ticketNum);
                    } else {
                        break;
                    }
                }
            }
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }
}
